<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="项目编码">
              <a-input placeholder="请输入项目编码" v-model="queryParam.projectCode"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="项目名称">
              <a-input placeholder="请输入项目名称" v-model="queryParam.projectName"></a-input>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="项目状态">
                <j-dict-select-tag
                  placeholder="请选择项目状态"
                  v-model="queryParam.status"
                  dictCode="sys_common_status"
                />
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text, record">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            :preview="record.id"
            height="25px"
            alt=""
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <template v-if="record.status == 1">
            <a-popconfirm title="确定通过吗?" @confirm="() => handleAudit(record, 2)">
              <a>通过</a>
            </a-popconfirm>
            <a-divider type="vertical" />
            <a-popconfirm title="确定驳回吗?" @confirm="() => handleAudit(record, 3)">
              <a>驳回</a>
            </a-popconfirm>
            <a-divider type="vertical" />
          </template>
          <a @click="handleDetail(record)">详情</a>
        </span>
      </a-table>
    </div>

    <ex-charge-setting-modal ref="modalForm" @ok="modalFormOk"></ex-charge-setting-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ExChargeSettingModal from './SettingModule'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import { httpAction, getAction } from '@/api/manage'
export default {
  name: 'AuditList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    ExChargeSettingModal,
  },
  data() {
    return {
      description: '资费设置管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '项目编码',
          align: 'center',
          dataIndex: 'projectCode',
        },
        {
          title: '项目名称',
          align: 'center',
          dataIndex: 'projectName',
        },
        {
          title: '标书费是否收取',
          align: 'center',
          dataIndex: 'bsfIsSq',
          customRender: function (t) {
            return t == 2 ? '不收取' : '收取'
          },
        },
        {
          title: '投标保证金是否收取',
          align: 'center',
          dataIndex: 'tbbzjIsSq',
          customRender: function (t) {
            return t == 2 ? '不收取' : '收取'
          },
        },
        {
          title: '投标保证金是否退还',
          align: 'center',
          dataIndex: 'tbbzjIsTh',
          customRender: function (t) {
            return t == 2 ? '不退还' : '退还'
          },
        },
        {
          title: '投标保证金收取方式',
          align: 'center',
          dataIndex: 'tbbzjSqfs',
          customRender: function (t) {
            return t == 2 ? '不收取' : '收取'
          },
        },
        {
          title: '投标保证金计算方式',
          align: 'center',
          dataIndex: 'tbbzjJsfs',
          customRender: function (t) {
            return t == 1 ? '定额' : ''
          },
        },
        {
          title: '投标保证金是否支持保函收取',
          align: 'center',
          dataIndex: 'tbbzjIsBhsq',
          customRender: function (t) {
            return t == 2 ? '不支持' : '支持'
          },
        },
        {
          title: '项目状态',
          align: 'center',
          dataIndex: 'status_dictText',
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/exChargeSetting/exChargeSetting/list',
        delete: '/exChargeSetting/exChargeSetting/delete',
        deleteBatch: '/exChargeSetting/exChargeSetting/deleteBatch',
        exportXlsUrl: '/exChargeSetting/exChargeSetting/exportXls',
        importExcelUrl: 'exChargeSetting/exChargeSetting/importExcel',
        audit: 'exChargeSetting/exChargeSetting/audit',
      },
      dictOptions: {},
      superFieldList: [],
      queryParam: {
        status: '1',
      },
    }
  },
  created() {
    this.getSuperFieldList()
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    initDictConfig() {},
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'projectId', text: '项目id', dictCode: '' })
      fieldList.push({ type: 'string', value: 'projectCode', text: '项目编码', dictCode: '' })
      fieldList.push({ type: 'string', value: 'projectName', text: '项目名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'bsfIsSq', text: '标书费是否收取', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tbbzjIsSq', text: '投标保证金是否收取', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tbbzjIsTh', text: '投标保证金是否退还', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tbbzjSqfs', text: '投标保证金收取方式', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tbbzjJsfs', text: '投标保证金计算方式', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tbbzjIsBhsq', text: '投标保证金是否支持保函收取', dictCode: '' })
      fieldList.push({
        type: 'string',
        value: 'status',
        text: '项目状态',
        dictCode: 'sys_common_status',
      })
      this.superFieldList = fieldList
    },
    handleAudit(row, status) {
      var that = this
      httpAction(this.url.audit, { id: row.id, status: status }, 'post')
        .then((res) => {
          if (res.success) {
            that.$message.success(res.message)
            that.loadData()
          } else {
            that.$message.warning(res.message)
          }
        })
        .finally(() => {
          that.confirmLoading = false
        })
    },
    searchReset() {
      this.queryParam = { status: '1' }
      this.loadData()
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>